package com.other;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

import org.springframework.util.StringUtils;

public class TestJava {

	public static void main(String[] args) {
		TestJava t = new TestJava();
		t.test1();
		t.test2();
	}

	public void test1() {
		String[] activeProfiles = {"test","deve"};
		List<String> profiles = Arrays.asList(activeProfiles);
		
		List<String> presetProfiles = new ArrayList<>(Arrays.asList("dev", "test", "prod"));
		
		presetProfiles.retainAll(profiles);
//		profiles.retainAll(presetProfiles);
		System.out.println(presetProfiles);
		
//		List<String> activeProfileList = new ArrayList<>(profiles);
		Function<Object[], String> joinFun = StringUtils::arrayToCommaDelimitedString;
		String activePros = joinFun.apply(profiles.toArray());
		System.out.println(activePros);
		
		String activePros1 = StringUtils.arrayToCommaDelimitedString(profiles.toArray());
		System.out.println(activePros1);
	}
	
	public void test2() {
		Function<Integer, String> verboseLambda = (Integer x)-> { return Integer.toString(x*x); };
		System.out.println(verboseLambda.apply(5));
		
		Function<Integer, String> conciseLambda1 = a -> Integer.toString(a*a);
		System.out.println(conciseLambda1.apply(10));
	}
}
